import request from '@/utils/request'

export function getUsers(data) {
  return request({
    url: '/api/user/user_list',
    method: 'get',
    params: {
      nickname: data.nickname,
      group_id: data.group_id,
      page: data.page,
      limit: data.limit
    }
  })
}
export function addUser(data) {
  return request({
    url: '/api/user/create_user',
    method: 'post',
    data: {
      username: data.account,
      password: data.password,
      re_password: data.checkPass,
      nickname: data.name,
      mobile: data.mobile,
      group_id: data.roles_id
    }
  })
}
export function editUser(data) {
  return request({
    url: '/api/user/change_user_info',
    method: 'post',
    data: {
      user_id: data.uid,
      nickname: data.name,
      password: data.password,
      re_password: data.checkPass,
      phone: data.mobile,
      group_id: data.roles_id
    }
  })
}
export function getRoles() {
  return request({
    url: '/api/user/get_group_list',
    method: 'get'
  })
}
// 删除用户
export function deleteUser(data) {
  return request({
    url: '/api/user/del_user',
    method: 'post',
    data: {
      user_ids: data
    }
  })
}

// 修改密码
export function updatePass(data) {
  console.log(data)
  return request({
    url: '/api/user/reset_pwd',
    method: 'post',
    data: {
      oldpassword: data.oldPass,
      newpassword: data.newPass
    }
  })
}
